package br.com.cast.syscast.persistencia;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;

public class DAOBase {
	
	@Autowired
	private DataSource dataSource;
	
	private Connection connection;
	
	protected Connection getConnection() {
		if (connection == null) {
			try {
				connection = dataSource.getConnection();
			} catch (SQLException e) {
				throw new RuntimeException(e);
			}
		}
		return connection;
	}

}
